let dd = new Date()
console.log(dd.toLocaleString())

let fn = n => n.toString().padStart(2, 0)
//console.log(fn(6), fn(16))
let ft = d => {
    let vs = [d.getFullYear(), d.getMonth() + 1, d.getDate()].map(e => fn(e)).join("-")
    let vt = [d.getHours(), d.getMinutes(), d.getSeconds()].map(e => fn(e)).join(":")
    return vs.concat(' ').concat(vt)
}

let fd = d => {
    let vs = [d.getFullYear(), '年', fn(d.getMonth() + 1), '月', fn(d.getDate()), '日']
    return vs.join('').concat(' 星期').concat('日一二三四五六'.charAt(d.getDay()))
}
//1680244882222
console.log(fd(new Date(1680244882222)))

//计算两个日期有多少天
//let d1 = new Date('2023-1-1') //2023-01-01 00:00:00
// let d1 = new Date('2023-1-1 14:52:55') //2023-01-01 14:52:55
//let d1 = new Date(2023, 1 - 1, 1, 14, 52, 55)
let d1 = new Date('2023-3-1 00:00:00')
console.log('d1', ft(d1))
let d2 = new Date()
console.log(ft(d2))
let days = (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24)
console.log(`开始日期：${ft(d1)} 到结束日期: ${ft(d2)} 之间有：${Math.round(days)}天`)

//5天前
console.log(ft(new Date(new Date().getTime() - (5 * 1000 * 60 * 60 * 24))))
//2天后
console.log(ft(new Date(new Date().getTime() + (2 * 1000 * 60 * 60 * 24))))
//100小时后
console.log(ft(new Date(new Date().getTime() + (1000 * 60 * 60 * 100))))

//console.log([new Date().getFullYear(), new Date().getMonth(), new Date().getDate()].join('-'))
//计算今日开始时间
console.log(ft(new Date([new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate()].join('-'))))



